﻿<cfsilent>
	<cfscript>
	
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		
		event.setArg("pageTitle", "制卷单");
		
		/* 考试相关 */
		examId = event.getArg("EXID");
		examType = event.getArg("ExamType");
		
		/* 学校信息 */
		sql = "SELECT sch_name, sch_name_eng FROM t_school ";

		queryObj = new Query( datasource=application.dnsSlave );
			
		rs_school = queryObj.execute( sql=sql ).getResult();
		
		
		/* 考试安排信息 */
		sql = "SELECT 
				a.wid, a.wdidx, 
				b.cellidx, b.time_start, b.time_end, 
				c.course_name, c.course_code, 
				d.institute_name, 
				e.academic_year, e.academic_term, e.term_start 
				FROM t_examtask a 
				INNER JOIN t_examcell b ON a.cellidx = b.cellidx 
				INNER JOIN t_course c ON a.cid = c.cid 
				INNER JOIN t_institute d ON d.institute_id = c.institute_id 
				INNER JOIN t_term e ON e.term_id = a.term_id 
				WHERE 
					a.task_exid = :examId 
					AND 
					a.task_prog = '3' ";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="examId", value=examId, cfsqltype="cf_sql_char" );
		
		rs_exam = queryObj.execute( sql=sql ).getResult();
		
		
		/* 考场分布 */
		sql = "SELECT 
				count(*) student_count, b.classroom 
				FROM t_student_exam a 
				INNER JOIN t_classroom b ON a.cr_id = b.cr_id  
				WHERE 
					a.task_exid = :examId 
				GROUP BY b.cr_id, b.classroom
				ORDER BY b.cr_id ";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="examId", value=examId, cfsqltype="cf_sql_char" );
		
		rs_place = queryObj.execute( sql=sql ).getResult();
		
		tagCode = "EXP-" & examId;
		
		/* 计算参考人数 */
		countNum = 0;
		
		for ( a=1; a LTE rs_place.recordCount; a++ ) {
			countNum += rs_place["student_count"][a];
		}
		
	</cfscript>
</cfsilent>

<div class="UIreportTitle">
	<h3>《<cfoutput>#rs_exam.course_name#</cfoutput>》<cfoutput>#dictAdvice.getMarkTurnName( examType )#</cfoutput> 制卷单</h3>
</div>

<cfif rs_exam.recordCount>

	<div class="UIreportFoot">
		<table class="big">
			<tr height="40">
				<td>开课学院： <cfoutput>#rs_exam.institute_name#</cfoutput></td>
				<td align="right"><cfoutput>#rs_exam.academic_year#</cfoutput> 学年 第 <cfoutput>#rs_exam.academic_term#</cfoutput> 学期</td>
			</tr>
		</table>
	</div>

	<table class="UIreportTable">
		<tr>
			<td width="70">考试科目</td>
			<td><cfoutput>#rs_exam.course_name#</cfoutput></td>
			<td width="60" align="center">考场数</td>
			<td align="center" width="49"><cfoutput>#rs_place.recordCount#</cfoutput></td>
			<td width="70" align="center">考试人数</td>
			<td align="center" width="49"><cfoutput>#countNum#</cfoutput></td>
		</tr>
	</table>
	<table class="UIreportTable">
		<tr>
			<td width="70">课程代码</td>
			<td><cfoutput>#rs_exam.course_code#</cfoutput></td>
			<td width="70">试题页码</td>
			<td width="180" align="center">A卷&nbsp;&nbsp;&nbsp;&nbsp;页，B卷&nbsp;&nbsp;&nbsp;&nbsp;页</td>
			<td width="130" align="center"><input type="checkbox"/> 开卷 <input type="checkbox"/> 闭卷</td>
		</tr>
	</table>
	<table class="UIreportTable">
		<tr>
			<td width="70">考试时间</td>
			<td><cfoutput>#datetimeAdvice.formatDateString( mathAdvice.revertTaskWeekDay( rs_exam.term_start, rs_exam.wid, rs_exam.wdidx ), "YYYY 年 MM 月 DD 日")#</cfoutput> <cfoutput>#datetimeAdvice.formatTimeString( rs_exam.time_start, "HH:MI" )#</cfoutput> 至 <cfoutput>#datetimeAdvice.formatTimeString( rs_exam.time_end, "HH:MI" )#</cfoutput></td>
			<td width="70">考试场次</td>
			<td align="center">第<cfoutput>#rs_exam.wid#</cfoutput>周 <cfoutput>#mathAdvice.convertWeekDayToChinese( rs_exam.wdidx )#</cfoutput> <cfoutput>#mathAdvice.convertExamIdxToChinese( rs_exam.cellidx )#</cfoutput></td>
		</tr>
	</table>
	<table class="UIreportTable">
		<tr>
			<td width="70">考试地点</td>
			<td>
				<div style="height:500px;">
					<!--- 考场清单 --->
					<table class="UIrowTable">
						<tr>
							<cfset row = 0 />
							<cfset cellPerRow = 6 />
							<cfloop query="rs_place">
								<cfset row++ />
								<td><cfoutput>#rs_place.classroom#</cfoutput><span class="numeric">(<cfoutput>#rs_place.student_count#</cfoutput>)</span></td>
								<cfif row mod cellPerRow eq 0>
						</tr>
						<tr>
								</cfif>
							</cfloop>
							<cfif row eq rs_place.recordCount and rs_place.recordCount mod cellPerRow>
								<cfloop from="1" to="#cellPerRow-rs_place.recordCount mod cellPerRow#" index="i">
									<td><!-- <cfoutput>holder<cfoutput>#i#</cfoutput> --></cfoutput></td>
								</cfloop>
							</cfif>
						</tr>
					</table>
				</div>
			</td>
		</tr>
	</table>
	<table class="UIreportTable">
		<tr>
			<td width="70">每考生<br/>需准备</td>
			<td align="center"><input type="checkbox"/> 答题纸</td>
			<td width="50">草稿纸</td>
			<td align="center">8开&nbsp;&nbsp;&nbsp;张, 16开&nbsp;&nbsp;&nbsp;张</td>
			<td align="center"><input type="checkbox"/> 外语专用机读卡</td>
		</tr>
	</table>

	<div class="UIreportFoot">
		<table>
			<tr height="40">
				<td>试卷印制审批</td>
			</tr>
		</table>
	</div>

	<table class="UIreportTable">
		<tr>
			<td>试卷制作要求</td>
			<td>命题人</td>
			<td>教研室<br/>负责人签字</td>
			<td>主管教学<br/>领导签字</td>
		</tr>
		<tr>
			<td>
				<input type="checkbox"/> 试卷命题严格遵守学校考试相关文件规定 <br />
				<input type="checkbox"/> 考试内容符合人才培养目标和教学大纲要求 <br />
				<input type="checkbox"/> 试卷采用本科试卷模版制作、打印，字迹清晰，卷面整洁 <br />
				<input type="checkbox"/> 装袋内容为该课程的A、B卷试题及其参考答案及评分标准
			</td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
	</table>

	<div class="UIreportFoot">
		<table>
			<tr>
				<td>打印时间 <cfoutput>#dateFormat(now(), "YYYY年MM月DD日")#</cfoutput></td>
				<td align="right"><img src="<cfoutput>#getContextRoot()#</cfoutput>/barcode/Print/<cfoutput>#tagCode#</cfoutput>.png" height="43"/></td>
			</tr>
		</table>
	</div>
	
</cfif>
